package com.lxl.priv.bak;

import cn.hutool.core.util.StrUtil;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @Author xiulong.liu
 * @Date 2024/10月/11/星期五 15:56
 * @Desc
 */
public class CsvHead {
    public static void main(String[] args) {
        boolean isYl = false;
        int extraLen = 2;
        //String[] values = new String[]{"id", "card", "phone","y"};
        String[] values = new String[]{"id", "card", "phone"};
        //String[] values1 = new String[]{"id","extr1", "extr2","y"};
        String[] values1 = new String[]{"id", "extr1", "extr2"};
        String[] arr = isYl ? new String[values.length]
                : new String[values.length + 1];
        for (int i = 0; i < values.length; i++) {
            arr[i] = values[i];
            if (!isYl) {
                arr[i + 1] = "label";
            }
            boolean flag = checkData(arr);
            if (flag) {
                for (String s : arr) {
                    System.out.println("s = " + s);
                }
            }
        }
        // 第二个文件
        List<String> list = Arrays.asList(arr);
        List<String> list1 = new ArrayList<>();
        list1.addAll(list);
        if (isYl) {
            for (int len = extraLen; len > 0; len--) {
                list1.add(list1.size() - 1, values1[values1.length - 1 - len]);
            }
        } else {
            for (int len = extraLen; len > 0; len--) {
                list1.add(list1.size() - 1, values1[values1.length - len]);
            }
        }
        for (String str : list1) {
            System.out.println("str = " + str);
        }


    }

    private static boolean checkData(String[] arr) {
        for (String str : arr) {
            if (StrUtil.isEmpty(str)) {
                return false;
            }
        }
        return true;
    }
}
